import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.chengfei.entity.LastGameUser;
import org.junit.Test;
import utils.AESUtil;
import utils.FileUtil;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * PoiTest class
 *
 * @author chengfei5
 * @date 2018/5/9
 */

public class PoiTest1 {
    private String seed = "a050969fa0d4439e";
    private String iv = "ad8eecf24af89268";

    @Test
    public void read1() throws Exception {
        String fileName = "D:\\京东彩娱\\from 刘梦楠\\【旅行季夺宝赛】用户加密码\\京东总决赛获奖名单.xls";
        File file = new File(fileName);
        ImportParams params = new ImportParams();
        params.setTitleRows(1);
        params.setHeadRows(1);
        ImportParams importParams = new ImportParams();
        ExcelImportResult<LastGameUser> result = ExcelImportUtil.importExcelMore(new FileInputStream(file), LastGameUser.class,
                importParams);


        List<LastGameUser> list = result.getList();
        List<LastGameUser> newList = new ArrayList<LastGameUser>();
        for (LastGameUser people : list) {
            people.setUserPin(AESUtil.decrypt(people.getOpenId(), seed, iv));
            newList.add(people);
            System.out.println(people.getId() + "--" + people.getOpenId() + "---" + AESUtil.decrypt(people.getOpenId(), seed, iv));
        }
        FileUtil.exportExcel(newList, "导出userPin", "sheet1", LastGameUser.class, fileName);
    }

    @Test
    public void test() {
        //测试环境
        String seed1 = "cd49c34d7e0aoahz";
        String iv1 = "cd49c34d7e0a4971";
        System.out.println(AESUtil.decrypt("P8gklqPXeweP4ZIQgXzX3XNuZWNkgUqDjReC948sX3k*", seed, iv));

    }

    @Test
    public void test1() {
        String userPin = "brTIhKygRjQs8DXmyB5KJw**\n" +
                "_aMZ4kFDY-NKCt2XnLo-tA**\n" +
                "O1XaKJuWDT-Xw9uZr4RU-4DZuuKIfh8tX4Zcx4c2at4*\n" +
                "AJ-i9tCkCYkleJmEMjVZpQ**\n" +
                "WNSS4X2TdUk1MXDqC642VeBOs66PqGFNMTrUz3v69qI*\n" +
                "teCBB3qcm-Y3umd2MFkoH3JVACOI6KgVoLApQujfFoA*\n" +
                "E9vRR3ABCQZQRnlT1MJSbA**\n" +
                "jBEzgS77C6iwfI0hVyrmHA**\n" +
                "Lx9rtDWUfI3wqkg2CxVMUQ**\n" +
                "52WuCfqVQAcMRP9TmFw656QJ5TX6VEecq6sAxSDQVIY*\n" +
                "IDOOfqjeyZT0e5iM13qcuw**\n" +
                "3paTPY2iBATP5_TiSwnqJlKLNIlwnVqXcKJOmQVUKN8*\n" +
                "ARqNJNLW8ZNgphNd3MNdAg**\n" +
                "0q1y15feCAu1Q5smj0U_er0-63cyvfvwgPAMnAKtSoo*\n" +
                "2FU1gfrwgTCk5iSP5fDN4A**\n" +
                "YJrANphGfNNPT-vi578KTdxY80hGpsE6-1y6PECEdqY*\n" +
                "qIbKp9MpYsAC5l73GWvOgA**\n" +
                "0dWkk40M6vIp7ioFOeRuP74opn2Mt6e7__nfVHZGklU*\n" +
                "JZKTjP3qH51kPjRQOO3VYYnMB6zfRw7SK0zGZBalxZM*\n" +
                "iqqopFNDB6_DWnkkbxGh4A**\n" +
                "H4uAmat1O8DmrVCRA7mOXw**\n" +
                "3Di0LnWEOTATflh2Bm0MtA**\n" +
                "xrQ_YhAyYqJmIu8pEf-HGw**\n" +
                "lfe2lcnq6LBElXdFRs1saw**\n" +
                "y1MYM4EZ2517CRTHrbgEOw**\n" +
                "nsery1l4WwyskRZ-5wKeZQ**\n" +
                "UzjbmTpkGGypIvomiTNtHw**\n" +
                "Np-BaQeB59g_LTKtjqGRbT6DJjm84_kQcohsxEmnKag*\n" +
                "y1hupS2FZNv5IOZwnGcD1w**\n" +
                "JYUYA2jTf1EnIt39Mx1VsQ**\n" +
                "_LxSV5_IZrveeaAr9RWSh42iw_xsZ08vm2jTvBbjMLg*\n" +
                "ENbKZ70M7tKuHpFW8N7CKw**\n" +
                "jbpOxR0IxliuNEM7sXfzPQ**\n" +
                "0nU_0leUUPqeHs3fepJjLg**\n" +
                "9WadCKGrll8pdQgiZOMtmMXMKHf2lZmO129iphP5mXU*\n" +
                "Y2MBqd4CNu3Gwnse8bVFzw**\n" +
                "22liOUwYIZUccwZa7C9kJw**\n" +
                "BMRfFYs1ZET73Cw-FyLM6g**\n" +
                "G1kXPATVzwwAKRIpPBeP55P9v3tdVf1LtiUmVB5VqJ0*\n" +
                "8cnQgEiD27htWdG3KpEhqA**\n" +
                "ui1lWB6NsZaAKU7VwbXXmw**\n" +
                "mgHobuL-U5xo-vAn2Atwhw**\n" +
                "XT6RXAYxmh1O1qmwiaOEpg**\n" +
                "RM17OsM6Zxec35L_bAypX2np7O8rWj5RuaTewIgfJMg*\n" +
                "1oPWF8YTXoeBABW5oHEhpwuoVHV0ZIA0sZnDoiIUcSI*\n" +
                "M5CL1Fq31oSYP-6DPToeLQ**\n" +
                "vJU2tWpwLDhvShWYUA9nmg**\n" +
                "myA_-F3GwPIIW7Nqk6kJ9Q**\n" +
                "CyTQeBirRIjDWTX0bp6vxcUYWVTr9ZDeKQpz1oAle6Q*\n" +
                "MgwjMaBfCGJ1OCYfCSnwZUrC7EAlWxJ-Qv357E9ZPb8*\n" +
                "wnAGxtjTD0i_JqElxS1tcl6PWxy8YDcrH4EEnND-_wg*\n" +
                "U4kFBhJsLpnrwdLSOX10Z0ugBd1nvvFolKLBQMs1tuo*\n" +
                "O9R17DD2Dm1JEsAEkQ_hgA**\n" +
                "gUNyN_34FNtyS_7vA1E4RQ**\n" +
                "uXdzZCEqwzVGW1b-pCt5sw**\n" +
                "srMCWy5i7uoVZYXZP28BUA**\n" +
                "jh7Mw-7Fa7u9FdN4ps5tOJYKpsedCnnDEVt6lm3HWyY*\n" +
                "TlyZTGZfwijQojWJx6n3tQ**\n" +
                "ODkAbtJuCLMD-d3n_8-yZQ**\n" +
                "iB0h568U7d54nZLCCTjmgw**\n" +
                "Vdnd0jfq_w_lFtq-_J40dw**\n" +
                "wTkY9D9_qCCEc8wuxT6oKw**\n" +
                "vSKVUA9N1Rboqj5N8nSB1T7HKGawAbOkCygOQZ1rPr8*\n" +
                "yICo91Fnevo65pnKdrqL5Q**\n" +
                "-NZvUZ0wS3rmOt-A1llEtg**\n" +
                "mFfNEv4gDmO4-yWDCgv3jgYdT55V0bdsodUsuvUI2zA*\n" +
                "0zPT-m4yxmxXOPiJQqP3Ag**\n" +
                "1r19_9JmRuqjIVDV4W7axg**\n";

        String[] split = userPin.split("\n");
        for (String pin : split) {
            System.out.println(pin+"----"+AESUtil.decrypt(pin, seed, iv));
        }

        System.out.println();
        for (String pin : split) {
            System.out.println(AESUtil.decrypt(pin, seed, iv));
        }
    }

}
